package com.genntii.examManager.common.handler;

import com.genntii.examManager.common.exception.BaseException;
import com.genntii.examManager.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class BaseExceptionHandler {

    @ExceptionHandler
    @ResponseBody
    public Result exceptionHandler(BaseException ex){
        log.error("错误信息：{}",ex.getMessage());
        return Result.error(ex.getMessage());
    }

}
